"use client"

import { Card, CardContent } from "@/components/ui/card"
import { cn } from "@/lib/utils"
import { Truck, MapPin } from "lucide-react"

interface DeliveryOptionProps {
  type: "pickup" | "delivery"
  selected: boolean
  onSelect: () => void
  fee: number
}

export function DeliveryOption({ type, selected, onSelect, fee }: DeliveryOptionProps) {
  const isDelivery = type === "delivery"

  return (
    <Card
      className={cn(
        "cursor-pointer transition-all duration-200 hover:shadow-md",
        selected ? "ring-2 ring-primary border-primary bg-primary/5" : "border-border hover:border-primary/50",
      )}
      onClick={onSelect}
    >
      <CardContent className="p-4">
        <div className="flex items-center gap-3">
          <div
            className={cn(
              "w-10 h-10 rounded-full flex items-center justify-center",
              selected ? "bg-primary text-primary-foreground" : "bg-muted",
            )}
          >
            {isDelivery ? <Truck className="h-5 w-5" /> : <MapPin className="h-5 w-5" />}
          </div>

          <div className="flex-1">
            <h3 className="font-medium">{isDelivery ? "送货上门" : "到店自取"}</h3>
            <p className="text-sm text-muted-foreground">
              {isDelivery ? "直接送到宿舍门口，方便快捷" : "到店自取，节省配送费用"}
            </p>
          </div>

          <div className="text-right">
            <p className="font-semibold">{fee > 0 ? `+¥${fee.toFixed(1)}` : "免费"}</p>
            {isDelivery && <p className="text-xs text-muted-foreground">配送费</p>}
          </div>
        </div>
      </CardContent>
    </Card>
  )
}
